<?
	
	class Package_Longtext0v0r00 extends _smuoiPackage{

		protected $default_rowclass = 'blob';
		
		protected $linked_blobs;
		
		function retrieve_my($m, $row, $do=false){
			$id = $row->id;
			if(isset($this->linked_blobs[$id]) && isset($this->linked_blobs[$id][$m])) return $this->linked_blobs[$id][$m];
			$t = $this->table('longtext');
			if((!$data = $this->db->open()->select('*', $t, array('lnk'=>$id, 'mem'=>$m))) && !$do) return false;
			$b = $this->linked_blobs[$id][$m] = ($data) ? $this->db->register($data[0], $t, 1, 1) : $this->new_blob(false, $id, $m);
			return $b;
		}
		
		function new_id(){
			return $this->key('longtext').base_convert(utime(), 10, 36);
		}
		
		function new_blob($blob=false, $lnk=false, $m=false){
			require_once $this->path_to_dataclass('blob');
			$class = $this->apply_namespace('blob');
			return new $class(false, $this, array('blb'=>$blob, 'lnk'=>$lnk, 'mem'=>$m));
		}
		
		function unlink($lnk){
			if($lnk instanceof _smuoiDbRow) $lnk = $lnk->id;
			return $this->al()->delete($this->table('longtext'), array('lnk'=>$lnk));
		}
		
		function duplicate($ltxt, $lnk=false){
			if(!$this->test_instanceof($ltxt, 'blob') && (!$ltxt = $this->db->get($ltxt))) return false;
			if(!$lnk) $lnk = $ltxt->lnk;
			return $this->newblob($ltxt->get_string(), $lnk);
		}
		
	}
	
?>